import time
from A3mall.Base.Base import Base
from selenium.webdriver.common.by import By
# 页面类
class Page(Base):
# 定位器
    # 点击登录
    login_loc=(By.LINK_TEXT,'登录')
    # 断言1：会员登录
    dy1_loc=(By.CLASS_NAME,'reg-new')
    # 输入账号
    username_loc=(By.NAME,'username')
    # 输入密码
    password_loc=(By.NAME,'password')
    # 点击登录按钮
    loginbtn_loc=(By.CSS_SELECTOR,'.finish-btn')
    # 断言2：欢迎回来，18986670716
    dy2_loc=(By.XPATH,'/html/body/div[1]/div/div[2]/ul/li[1]/a')

    def login(self):
        self.click(self.login_loc)

    def dy1(self):
        self.text(self.dy1_loc)

    def username(self):
        self.send_keys(self.username_loc,'18986670716')

    def password(self):
        self.send_keys(self.password_loc,'a123456')

    def loginbtn(self):
        self.click(self.loginbtn_loc)

    def dy2(self):
        self.text(self.dy2_loc)

    # 逻辑
    def a3mall_luoji1_login(self):
        self.open_url('http://10.59.9.12:7001/')
        self.login()
        # print(self.dy1())
        # assert '会员登录' == self.dy2_loc
        self.username()
        self.password()
        # 强制等待
        time.sleep(10)
        self.loginbtn()
        time.sleep(2)
        print(self.dy2())
        # assert '欢迎回来，18986670716' == self.dy2_loc
        # time.sleep(5)

